<?php
namespace app\wechat\controller;
use app\models\Bases;

class Text extends Base{
    /**
     * @return \think\response\Json
     * 文字直播信息
     */
    public function textList(){
        $textChat = new Bases('text_play');
        try{
            $start = strtotime(date('Y-m-d')); //今天的开始时间
            $end  = $start + 3600*24;    //今天的结束时间
            $result = $textChat->selectData("create_time >= $start and create_time < $end"); //查询今天的所有信息
            if(!$result){
                throw new \LogicException('无信息',10010);
            }
            foreach($result as $k=>$v){
                $result[$k]['content'] = html_entity_decode($v['content']);
            }
        }catch(\Exception $e){
            return json(self::formatResult($e->getCode(),$e->getMessage()));
        }
        return json(self::formatSuccessResult($result));
    }
}